import { MAP_BEFORE_INFO, REMOVE_MAP } from 'Constants/chooseMap';

const initialState = {
  mapBeforeInfo: sessionStorage.getItem('MapBeforeInfo') || '',
};
export default function ChooseMapInfo(state = initialState, action) {
  switch (action.type) {
    case MAP_BEFORE_INFO:
      return Object.assign({}, state, {
        mapBeforeInfo: action.mapInfo.mapBeforeInfo,
      });
    case REMOVE_MAP:
      sessionStorage.removeItem('MapBeforeInfo');
      return Object.assign({}, state, { mapBeforeInfo: '' });
    default:
      return state;
  }
}
